package video

import (
	"context"
	"srv/config"
	"srv/internal/model/dao"
	__ "srv/proto"
)

// 定义空接口
type UserService struct {
	__.UnimplementedVideoServiceServer
}

// 实现方法
func (s *UserService) VideoAdd(ctx context.Context, req *__.VideoAddRequest) (resp *__.VideoAddReply, err error) {
	video := dao.Video{
		VideoName: req.VideoName,
		Url:       req.Url,
		UserId:    int(req.UserId),
		Location:  req.Location,
		To:        int8(req.Tos),
	}
	config.DB.Create(&video)
	var videos dao.Video
	config.DB.Where("video_name=?", req.VideoName).Limit(1).Find(&videos)
	return &__.VideoAddReply{VideoId: int64(video.ID)}, nil
}
